package edu.unlv.cs.ladders.security;

import java.util.Collection;

import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.vote.AbstractAclVoter;
import org.springframework.security.core.Authentication;

public class AdminVoter extends AbstractAclVoter implements AccessDecisionVoter {
	private static final String ADMIN_USER = "admin";
	public boolean supports(ConfigAttribute attribute) {
		return true;
	}

	public int vote(Authentication authentication, Object object,
			Collection<ConfigAttribute> attributes) {
		if(authentication.getName() == ADMIN_USER){
			return ACCESS_GRANTED;
		}
		return ACCESS_ABSTAIN;
	}

	@Override
	public boolean supports(Class<?> clazz) {
		return true;
	}
}
